package homework;

import java.util.Arrays;
import java.util.Random;

public class Day05Homework1 {
    public static void main(String[] args) {
        /*
        for(int num=1;num<10;num++){
            for(int i=1;i<=num;i++){
                System.out.print(i+"*"+num+"="+i*num+"\t");
            }
            System.out.println();
        }
        */
        /*
        int[] arr = new int[10];
        int[] arr1 = new int[3];
        int[] arr2 = {2,4,6};
        int[] arr3 = new int[]{3,6,9};
        int[] arr4;
        arr4 = new int[]{1,3,5};
        */
        /*
        int[] arr = new int[3];
        System.out.println(arr.length);
        arr[0]=1;
        arr[1]=2;
        arr[2]=300;
        System.out.println(arr[arr.length-1]);
        */
        /*
        int[] arr = new int[10];
        for(int i=0;i<arr.length;i++){
            arr[i]=(int)(Math.random()*100);
            System.out.println(arr[i]);
        }
        int[] a = {11,22,33,44,55};
        a = Arrays.copyOf(a,a.length+1);
        for(int i=0;i<a.length;i++){
            System.out.println(a[i]);
        }
        */
        /*
        int[] a={10,20,30,40,50,};
        int[] b=Arrays.copyOf(a,4);
        for(int i=0;i<b.length;i++){
            System.out.println(b[i]);
        }
        */
        /*
        int[] aa={1,2,3,4,5};
        int[] bb=new int[6];
        System.arraycopy(aa,2,bb,2,2);
        for(int i=0;i<bb.length;i++){
            System.out.println(bb[i]);
        }
         */
        /*
        int[] arr = new int[10];
        for(int i=0;i<arr.length;i++){
            arr[i]=(int)(Math.random()*100);
            System.out.println(arr[i]);
        }
        int max = arr[0];
        for(int i=0;i<arr.length;i++){
            if(arr[i]>max){
                max = arr[i];
            }
        }
        System.out.println("最大值为"+max);

        arr = Arrays.copyOf(arr,arr.length+1);
        arr[arr.length-1] = max ;
        for(int i=0;i<arr.length;i++){
            System.out.println(arr[i]);
        }
        */
        Random rand = new Random();
        int[] arr = new int[5];
        for(int i=0;i<arr.length;i++){
            arr[i] = rand.nextInt(100);
            System.out.println(arr[i]);
        }

        Arrays.sort(arr);

        System.out.println("排序后:");
        for(int i=0;i<arr.length;i++){
            System.out.println(arr[i]);
        }
        System.out.println("倒着输出");
        for(int i=arr.length-1;i>=0;i--){
            System.out.println(arr[i]);
        }
    }
}
